//
//  ViewController.m
//  ExclusiveTouchDemo
//
//  Created by wangyongkang on 17/6/13.
//  Copyright © 2017年 王永康. All rights reserved.
//

#import "ViewController.h"
#import "UIView+ExclusiveTouch.h"

#import <objc/runtime.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
//    [[UIView appearance] setExclusiveTouch:YES];
//    self.view.ygExclusiveTouch = YES;
    NSLog(@"self.view  %d  ",self.view.ygExclusiveTouch);
//    NSLog(@"self.view  %d  ",self.view.exclusiveTouch);
    self.view.backgroundColor = [UIColor whiteColor];
    UILabel *lab1 = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 175, 100)];
    lab1.backgroundColor = [UIColor purpleColor];
    
    lab1.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap1)];
    [lab1 addGestureRecognizer:tap1];
    [self.view addSubview:lab1];
    [lab1 setExclusiveTouch:NO];
    
    UILabel *lab2 = [[UILabel alloc] initWithFrame:CGRectMake(100, 300, 175, 100)];
    lab2.backgroundColor = [UIColor redColor];
    lab2.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap2)];
    [lab2 addGestureRecognizer:tap2];
    [self.view addSubview:lab2];
    [lab2 setExclusiveTouch:NO];
    
    
}

- (void)tap1
{
    NSLog(@"点击了tap1");
    
    UIViewController *vc = [[UIViewController alloc] init];
    vc.view.backgroundColor = [UIColor greenColor];
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)tap2
{
    NSLog(@"点击了tap2");
    UIViewController *vc = [[UIViewController alloc] init];
    vc.view.backgroundColor = [UIColor blueColor];
    [self.navigationController pushViewController:vc animated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
